#ifndef STATION_H
#define STATION_H


/*
  See cpp or doxygen for full documention
*/

//Our includes
class Leg;
class Survey;
#include "Vec3.h"

//STD includes
#include <string>
#include <vector>

/*!
  \class Station

  \brief Station base class.

  A station holds all the legs that are connected to it.

*/

class Station {
public:
    //Constructor
    Station();

    //Deconstruct
    virtual ~Station();

    /*!
    \brief Gets the Leg a the current index.
    Index starts at 0 and goes GetNumberOfLegs() - 1;
    */
    Leg* GetLeg(int index) const { return Legs.at(index); }

    //!Gets the number of Legs from this station
    int GetNumberOfLegs() const { return Legs.size(); }

    //Adds a Leg to the station
    void AddLeg(Leg* Leg);

    //Removes a Leg from the station
    void RemoveLeg(Leg* Leg);

    //Linearly searchs for a Leg and return's it's index
    int IndexOf(Leg* Leg);

    //Find if this station has this Leg
    bool HasLeg(Leg* Leg);

    //!Gets the position of the Leg
    const Vec3& GetPosition() { return Position; }

    /*!
        \brief Sets the parent survey

        A station can only be owned by one survey.  This is for
        naming proposes and finding stations by thier survey name.

        This is extremely useful for connecting two caves / surveyes.

        Also see GetSurvey()
        */
    void SetSurvey(Survey* survey) { ParentSurvey = survey; }

    /*!
        \brief Gets the parent survey

        Also see SetSurvey()
     */
    Survey* GetSurvey() { return ParentSurvey; }

    //!Get the name of the Station
    std::string GetName() { return Name; }

    /*! \brief Sets the name of the station
      \param name - The new name of the station

      NOTE: name must not contain any periods.  If periods exist
          station lookup by name will not work properly
          */
    void SetName(const std::string& name) { Name = name; }

    //Get's the stations full name
   std::string GetFullName();

    /*!
    \brief Sets the position of the station
    LIBRARY FUNCTION - YOU SHOULD NEVER HAVE TO CALL THIS.
    */
    void SetPosition(const Vec3& newPosition) { Position = newPosition; }

protected:

    //The position of the station after the loop closure
    Vec3 Position;

    //The base name of the station
    std::string Name;

    //Parent survey where this Leg was first created, useful for
    //name lookup
    Survey* ParentSurvey;

    //List of Legs from this station
    std::vector<Leg*> Legs;


};

#endif // STATION_H
